<?php

namespace app\common\model;
use think\Exception;

class CmsWebsite extends BaseModel
{
    //更新网站信息
    public function updateWebsiteInfo($data){
        $id=$data['id'];
        $data=$this->dataFilter($data);
        try{
            $result=$this->where("web_id","=",$id)->update($data);
        }catch (Exception $e){
            return "数据更新失败";
        }
        if(!$result){
            return "数据未发生变化";
        }else{
            $webInfo=$this->find($id);
            cache("webInfo",$webInfo);
            return 1;
        }
    }

    //返回cache中的指定数据
    function getCacheData($fields){
        $webInfo=cache("webInfo");
        if(!$webInfo){
            refreshWebInfoInCache();
            $webInfo=cache("webInfo");
        }
        return $webInfo[$fields];
    }
}
